package javaweb.mapper;

import javaweb.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;
/*
*
* 定义增删查改的接口
*
* */
@Mapper
public interface DeptMapper {

/*    //1.手动结果映射
    @Results({
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime")
    })*/


    /*//2.起别名
    @Select("select id, name, create_time createTime, update_time updateTime from dept order by update_time desc")*/
    @Select("select id, name, create_time, update_time from dept order by update_time desc")
    public List<Dept> findAllDept();

    //删除部门操作
    @Delete("delete from dept where id = #{id}")
    public void deleteDeptByID(String id);

    /*
    * 新增部门操作
    * */
    @Insert("insert into dept(name, create_time, update_time) values(#{name}, #{createTime}, #{updateTime})")
    public void insertDept(Dept dept);

    /*
    * 根据id查询部门
    * */
    @Select("select id, name, create_time, update_time from dept where id = #{id}")
    public Dept findById(Integer id);

    /*
    * 更新部门信息
    * */
    @Update("update dept set name = #{name}, update_time = #{updateTime} where id = #{id}")
    public void updateDept(Dept dept);
}
